﻿using System;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Dynamic.Data.Model.Query
{
    [DataContract]
    [XmlInclude(typeof(OrderExpression)), XmlType(Namespace="DynamicMatrix")]
    public sealed class QueryByAttribute : QueryBase
    {
        private string[] _attributeName;
        private object[] _attributeValue;
        private List<OrderExpression> _orders;
        private PagingInfo _pageInfo;

        public override void Accept(IQueryVisitor visitor)
        {
            visitor.Visit(this);
        }

        [DataMember]
        [XmlArrayItem(ElementName="Attribute", IsNullable=false, Type=typeof(string)), XmlArray]
        public string[] Attributes
        {
            get
            {
                return this._attributeName;
            }
            set
            {
                this._attributeName = value;
            }
        }

        [DataMember]
        [XmlArray, XmlArrayItem(ElementName="Order", IsNullable=false, Type=typeof(OrderExpression))]
        public List<OrderExpression> Orders
        {
            get
            {
                return this._orders;
            }
            set
            {
                this._orders = value;
            }
        }

        [DataMember]
        public PagingInfo PageInfo
        {
            get
            {
                return this._pageInfo;
            }
            set
            {
                this._pageInfo = value;
            }
        }

        [DataMember]
        [XmlArrayItem(ElementName="Value", IsNullable=true, Type=typeof(object)), XmlArray]
        public object[] Values
        {
            get
            {
                return this._attributeValue;
            }
            set
            {
                this._attributeValue = value;
            }
        }
    }
}

